﻿using BLevy.Entidad;
using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace BLevy.UI
{
    public partial class frmCuponesReporte : Form
    {
        private List<Cupon> cuponesL = new List<Cupon>();
        public frmCuponesReporte(List<Cupon> cupones)
        {
            cuponesL = cupones;
            InitializeComponent();
        }

        private void frmCuponesReporte_Load(object sender, EventArgs e)
        {
            try
            {
                var query = (from fila in cuponesL
                             select new
                             {
                                 fecha_emision = fila.fecha_emision,
                                 numero = fila.numero,
                                 id = fila.socio.numero_certificado,
                                 socio_id = fila.socio.apellido + ", " + fila.socio.nombres,
                                 total = fila.total,
                                 estado = fila.estado

                             }).ToList();

                ReportDataSource rds = new ReportDataSource();
                rds = new ReportDataSource("DataSet1", query);

                this.reportViewer1.LocalReport.ReportEmbeddedResource = "BLevy.UI.Reportes.CuponesReporte.rdlc";

                this.reportViewer1.LocalReport.DataSources.Add(rds);
                this.reportViewer1.ZoomMode = Microsoft.Reporting.WinForms.ZoomMode.PageWidth;
                this.reportViewer1.RefreshReport();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error : " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
    }
}
